package org.bedracket.pgeg.datagen;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.data.BlockTagsProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.bedracket.pgeg.PGEGMod;
import org.bedracket.pgeg.util.Helpers;
import org.jetbrains.annotations.Nullable;

import java.util.Set;
import java.util.concurrent.CompletableFuture;

public class ModBlockTagsProvider extends BlockTagsProvider {

    public ModBlockTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
        super(output, lookupProvider, PGEGMod.MOD_ID, existingFileHelper);
    }

    @Override
    protected void addTags(HolderLookup.Provider pProvider) {
        Set<Block> blocks = Helpers.getBlocks();
        blocks.stream().filter(block -> block.getDescriptionId().contains("infused_stone"))
                .forEach(this::needStoneTool);
        blocks.stream().filter(block -> block.getDescriptionId().contains("infused_stone"))
                .forEach(this::pickaxeAble);
        blocks.stream().filter(block -> block.getDescriptionId().contains("infused_deepslate"))
                .forEach(this::needStoneTool);
        blocks.stream().filter(block -> block.getDescriptionId().contains("infused_deepslate"))
                .forEach(this::pickaxeAble);
        blocks.stream().filter(block -> block.getDescriptionId().contains("_ore"))
                .forEach(this::needStoneTool);
        blocks.stream().filter(block -> block.getDescriptionId().contains("_ore"))
                .forEach(this::pickaxeAble);
    }

    void pickaxeAble(Block block) {
        tag(BlockTags.MINEABLE_WITH_PICKAXE).add(block);
    }

    void needStoneTool(Block block) {
        tag(BlockTags.NEEDS_STONE_TOOL).add(block);
    }
}
